# -*- coding: utf-8 -*-
"""This module provides the Story model for reporting news
"""
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.db.models import permalink

from pennypress.base.models import PennyPressBase

class Story(PennyPressBase):
    source = models.CharField(_("Other Story Sources"), max_length=200,\
                blank=True, null=True,)
    headline = models.CharField(max_length=100)
    slug = models.SlugField(_('Slug'), max_length=30, prepopulate_from=('title',))
    teaser = models.TextField(_("Teaser Text"))
    body = models.TextField(_("Body"))
    
    class Admin:
        list_display = ('headline', 'status', 'publish_date',\
                            'modified_date')
        list_filter = ('site', 'publish_date')
        search_fields = ('headline', 'summary', 'body')
        date_hierarchy = 'publish_date'
        list_per_page = 25
    
    class Meta(PennyPressBase.Meta):
        verbose_name = _("Story")
        verbose_name_plural = _("Stories")
    
    def get_absolute_url(self):
        return ('story_detail', (), {
            'section':self.section,
            'year':self.pub_date.year,
            'month':self.pub_date.strftime('%b').lower(),
            'day':self.pubish_date.day,
            'slug':self.slug
        }) 
    get_absolute_url = permalink(get_absolute_url)
    
    def __unicode__(self):
        return "%s : %s" % (self.headline, self.publish_date)
